#include "card.h"

Card::Card(int num, int upper) : nums(num)
{
    //数组初始化
    for(int i = 0; i < 4; i++)
        lowCardNumArr[i] = -1;
    QString str;
    if(upper)       //未被遮盖
    {
        str = QString(":/res/00%1.png").arg(num);
        this->isUpper = true;
    }
    else            //被遮盖
        str = QString(":/res/000%1.png").arg(num);
    this->setFixedSize(52, 57);
    this->setStyleSheet("QPushButton{border:0px}");
    this->setIcon(QIcon(str));
    this->setIconSize(QSize(this->width(), this->height()));
}

//鼠标按下 事件
void Card::mousePressEvent(QMouseEvent *e)
{
    //被翻开时 和 被遮盖时（拦截）
    if(this->isClicked || !this->isUpper)
    {
        return;
    }
    return QPushButton::mousePressEvent(e);
}
